package com.yulong.web.controller;


import com.fasterxml.jackson.annotation.JsonAlias;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.yulong.model.pojo.UmsMenu;
import com.yulong.web.server.Impl.UmsMenuServerImpl;
import com.yulong.web.server.UmsMenuServer;
import com.yulong.web.utils.ResponseMap;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

@RestController
@Api("菜单")
@RequestMapping("menu")
public class UmsMenuController {

    @Autowired
    private UmsMenuServerImpl umsMenuServer;


    @ApiOperation("list")
    @GetMapping(value = "/list")
    @ResponseBody
    public ResponseMap queryList() {
        Integer level = 0;
        ResponseMap responseMap = umsMenuServer.queryList(level);
        return responseMap;
    }

    @ApiOperation("create")
    @PostMapping(value = "/create")
    public ResponseMap create(@RequestBody UmsMenu umsMenu) {
        ResponseMap responseMap = umsMenuServer.create(umsMenu);
        return responseMap;
    }

    @ApiOperation("update")
    @PostMapping(value = "/update")
    public ResponseMap update(@RequestBody UmsMenu umsMenu) {
        ResponseMap responseMap = umsMenuServer.update(umsMenu);
        return responseMap;
    }


    @ApiOperation("delete")
    @GetMapping(value = "/delete/{id}")
    public ResponseMap delete(@PathVariable Long id) {
        ResponseMap responseMap = umsMenuServer.delete(id);
        return responseMap;
    }


    @ApiOperation("返回树状结构的菜单")
    @GetMapping(value = "treeList")
    public ResponseMap treeList() {
        ResponseMap responseMap = umsMenuServer.treeList();
        return responseMap;
    }


}

